package EA.testproblems;
import EA.*;
import RKUjava.util.*;


/**
   <br><br>

   <table border="0" cellpadding="2" cellspacing="0">
   <tr bgcolor="#a0a0a0">
   <td colspan="2" valign="top"><b>Problem description</b></td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top" width="200"><b>Name:</b></td>
   <td valign="top">Ursem multimodal 10</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Nickname:</b></td>
   <td valign="top">Sharing killer 1</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Intended usage:</b></td>
   <td valign="top">Experimentally show that sharing GAs can easily get in trouble.</td>
   </tr>

   <tr>
   <td colspan="2" valign="top">&nbsp;</td>
   </tr>
   <tr bgcolor="#a0a0a0">
   <td colspan="2" valign="top"><b>Problem details</b></td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Function:</b></td>
   <td valign="top">1 + (sin(5.1pi*x + 0.5)<sup>6</sup>*exp((-4*ln2*(x-0.1)<sup>2</sup>)/0.64))</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Plots:</b></td>
   <td valign="top"><img src="../../images/testproblems/ursemmultimodal10.gif">&nbsp;&nbsp;
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Ranges:</b></td>
   <td valign="top">x = [0:1]</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Type:</b></td>
   <td valign="top">Maximization</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>No. of maximas:</b></td>
   <td valign="top">5</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>No. of minimas:</b></td>
   <td valign="top">0</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Optimum radius:</b></td>
   <td valign="top">0.1</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Optimum descriptions:</b></td>
   <td valign="top">The maxima have the same height.</td>
   </tr>
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>Known optimums:</b></td>
   <td valign="top">
   <br><font size=1>Capital letters 
   means that the precise optimum is known, lowercase letters is the best known 
   so far.</font></td>
   </tr>
   <tr>
   <td colspan="2" valign="top">&nbsp;</td>
   </tr>
   <tr bgcolor="#a0a0a0">
   <td colspan="2" valign="top"><b>Plotting details</b></td>
   </tr>
   
   <tr bgcolor="#e0e0e0">
   <td valign="top"><b>GNUPlot code:</b></td>
   <td valign="top">
   set samples 250<br>
   plot [0:1] [0:1.1] 1 + ((sin(5.1*pi*x+0.5))**6)

   </tr>
   </table>
*/

public class UrsemMultimodal10_20 extends NumericalProblem {
    
    // Easier way to build max and min
    private double[][] lmax = {{((Math.PI-1)/(10.2*Math.PI))},
			       {((3*Math.PI-1)/(10.2*Math.PI))},
			       {((5*Math.PI-1)/(10.2*Math.PI))},
			       {((7*Math.PI-1)/(10.2*Math.PI))},
			       {((9*Math.PI-1)/(10.2*Math.PI))}};
    private double[][] lmin = new double[0][1];
    
    public UrsemMultimodal10_20() {
	super();
	
	double[] optimas;
	name = "Ursem multimodal F10";
	objectivefunction = new NumericalFitness() {
		public double Fitness_calcFitness_inner(double[] realpos) {
		    return 20 + Math.pow(Math.sin(5.1*Math.PI*realpos[0]+0.5),6);
		};
	    };
	
	dimensions = 1;
	ismaximization = true;
	optimumradius = 0.1;

	intervals = new Interval[dimensions];
	for (int i=0; i<dimensions; i++)
	    intervals[i] = new Interval(0.0, 1.0);


	// Set up known maxima
	knownmaxima = new NumericalOptimum[lmax.length];
	for (int i=0;i<lmax.length;i++) {
	    optimas = new double[dimensions];
	    for (int j=0;j<dimensions;j++) {
		optimas[j] = lmax[i][j];
	    }
	    knownmaxima[i] = new NumericalOptimum(optimas, objectivefunction.calcFitness(optimas), true, false, i);
	}
	
	// Set up known minima
	knownminima = new NumericalOptimum[lmin.length];
	
	for (int i=0;i<lmin.length;i++) {
	    optimas = new double[dimensions];
	    for (int j=0;j<dimensions;j++) {
		optimas[j] = lmin[i][j];
	    }
	    knownminima[i] = new NumericalOptimum(optimas, objectivefunction.calcFitness(optimas), false, false, i);
	}
	
    }
}
